#ifndef _CAMERA_API_H
#define _CAMERA_API_H

#ifdef __cplusplus
extern "C" {
#endif

#include "lv_drv_conf.h"

#if USE_CRANE_CAMERA

#include "../../board.h"
//#include "camera_api.h"

/* sensor position */
enum crane_sensor_pos {
    CAMERA_BACK = 0,
    CAMERA_FRONT,
    CAMERA_MAX,
};

/* camera param enum */
enum {
   CAM_PARAM_NONE=0,
   CAM_PARAM_ZOOM_FACTOR,
   CAM_PARAM_CONTRAST,
   CAM_PARAM_BRIGHTNESS,
   CAM_PARAM_HUE,
   CAM_PARAM_GAMMA,
   CAM_PARAM_WB,
   CAM_PARAM_EXPOSURE,
   CAM_PARAM_EFFECT,
   CAM_PARAM_BANDING,    //9  //add by WeiD
   CAM_PARAM_SATURATION,
   CAM_PARAM_NIGHT_MODE,
   CAM_PARAM_EV_VALUE,
   CAM_PARAM_FLASH,
   CAM_PARAM_FLASH_MODE=CAM_PARAM_FLASH,
   CAM_PARAM_AE_METERING,
   CAM_PARAM_AF_KEY,
   CAM_PARAM_AF_METERING,
   CAM_PARAM_AF_MODE,
   CAM_PARAM_MANUAL_FOCUS_DIR,
   CAM_PARAM_SHUTTER_PRIORITY,
   CAM_PARAM_APERTURE_PRIORITY,
   CAM_PARAM_ISO,
   CAM_PARAM_SCENE_MODE,
   CAM_PARAM_QUALITY, //2//23  //add by WeiD
   CAM_PARAM_IMAGESIZE, //24 add by WeiD
   CAM_PARAM_ADD_FRAME,//25,chenhe add
   CAM_NO_OF_PARAM
};

typedef enum{
    BANDING_50HZ    = 0,
    BANDING_60HZ    = 1,
    BANDING_AUTO    = 2,
}CAM_BANDING;

typedef enum PIPE_OUT_FMT
{
    PIPE_OUT_FMT_YUV422_YUYV = 0,/*1 planar*/
    PIPE_OUT_FMT_YUV422_YVYU,
    PIPE_OUT_FMT_YUV422_UYVY,
    PIPE_OUT_FMT_YUV422_VYUY,
    PIPE_OUT_FMT_YUV420_I420,/*3 planar  Y, U, V */
    PIPE_OUT_FMT_YUV420_YV12,/*3 planar  Y, V, U */
    PIPE_OUT_FMT_YUV420_NV12,/*nv12  YYYYYYYY UVUV */
    PIPE_OUT_FMT_YUV420_NV21, /*NV21  YYYYYYYY VUVU */
    PIPE_OUT_FMT_YUV422_3PLANAR,/*not support in offline*/
    PIPE_OUT_FMT_JPEG,
    PIPE_OUT_FMT_RAW8,/*bayer raw8  */
    PIPE_OUT_FMT_ONLY_Y,
}PIPE_OUT_FMT;

#define CAMERA_LCD_TEST         0

#if CAMERA_LCD_TEST
typedef int (*CameraCallBackHandle)(void *useData, void* pBufIndex);

typedef struct _CameraHalTestCallbackSturct {
    CameraCallBackHandle callBackHandle;
    void *userData;
} CameraHalTestCallbackSturct;

typedef struct _CameraHalTestBufPack {
    void *pBuf;
    int bufIndex;
    int bufStatus; //0 other, 1 us
} CameraHalTestBufPack;

void CameraHalTestInit(void);
#endif

int mci_camera_openpreview(void);
void mci_camera_stoppreview(void);
int mci_camera_capture(void *param, int file_handle);
int mci_camer_setpara(int32_t effectCode, int32_t value);
typedef int (*ReleaseBufferCallback)(void *, void *);
typedef void (*SetReleaseBufferCb)(ReleaseBufferCallback callBackHandle, void *userData);
typedef void (*EnqueueCamRecordBufferCb)(void *pBuf, int bufIndex);
typedef void (*FlushCamRecordBufferCb)(void);

void mci_camera_update(uint16_t width,
                   uint16_t height,
                   uint8_t *buf1,
                   uint8_t *buf2,
                   uint8_t semi);
unsigned mci_camera_preview(uint8_t *preview_buf, int preview_width, int preview_height);
unsigned mci_camera_preview_yuv_size(int *width, int *height);
unsigned mci_camera_preview_qrcode_scan(uint8_t *preview_buf, int preview_width, int preview_height);
void mci_camera_preview_reset(void);

int mci_camera_start_full_size_stream(CAM_RECORD_PARMETERS_STRUCT *pRecordParam, uint32_t format);
void mci_camera_stop_full_size_stream(void);

#if USE_CRANE_CAMERA_MULTI
enum {
    CAMERA_SENSOR_BACK = 0,
    CAMERA_SENSOR_FRONT,
};

/***
*** mci_camera_set_sensor should be called before mci_camera_openpreview.
*** mci_camera_set_sensor shouldn't be called between mci_camera_openpreview and mci_camera_stoppreview.
***/
void mci_camera_set_sensor(int sensor);

int mci_camera_get_sensor(void);

#endif

#endif /* USE_CRANE_CAMERA */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
